STEP 9: Let's now add a basketball inside of our click event, so it appears on the stage when we click our sprite.

  • First, delete this line that's inside of your click event: sprite.say("Hello,·name").
  • Then, in , drag in Basketball INSIDE your click event. It should be indented 4 spaces.
  • Finally, change the variable name to the left of the = sign from sprite to ball.
  • Click on your sprite to see basketballs appear on the stage! Click Next and Submit to move on.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("halfcourt") sprite = codesters.Sprite("player1") sprite.go_to(-175, -150) net = codesters.Sprite("basketballnet") net.go_to(215, 175) stage.set_gravity(10) sprite.set_gravity_off() def click(sprite): sprite.say("Hello, name") # add other actions... sprite.event_click(click)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)